<template>
  <view class="content" :style="{ paddingTop: statusBarHeight + 'px' }">
    <uni-nav-bar title="退货订单" fixed :border="false" height="88rpx" background-color="#f7f7f7" left-icon="left"
      @clickLeft="onClickLeft"></uni-nav-bar>
    <view class="topCard">
      <uni-search-bar v-model="returnsNumber" radius="100" placeholder="请输入" cancelButton="none"
        style="flex: 1;margin: 0;padding: 0;margin-right: 20rpx;" @confirm="searchFn" @clear="clearFn" />
    </view>
    <scroll-view class="scroll-view_H" scroll-y @refresherrefresh="refresherrefreshFn" refresher-enabled="true"
      :show-scrollbar="false" @scrolltolower="lower" :refresher-triggered="triggered" enhanced
      style="height: calc(100% - var(--window-top) - 168rpx);">
      <view class="infoCard2" v-for="(item, index) in orderList" :key="item.id + index"
        @click="$navTo('./refundOrderDetail', { id: item.id })">
        <view class="tokenNum">
          <view class="count u-ellipsis goodsname" style="width: 100% !important;">退货编号：{{ item.returnsNumber }}</view>
        </view>
        <view class="tokenNum">
          <view class="count" style="width: 80% !important;">订单编号：{{ item.orderNumber }}</view>
          <view class="count" style="width: 20% !important;">
            <uni-icons type="right" size="30"></uni-icons>
          </view>
        </view>
        <view class="tokenNum">
          <view class="count" style="width: 50% !important;">退款金额：{{ item.returnsMoney }}</view>
          <view class="count" style="width: 50% !important;" v-if="item.returnsMode == '0'">退款方式：现金退款</view>
          <view class="count" style="width: 50% !important;" v-if="item.returnsMode == '1'">退款方式：微信转账</view>
          <view class="count" style="width: 50% !important;" v-if="item.returnsMode == '2'">退款方式：支付宝转账</view>
        </view>
        <view class="tokenNum">
          <view class="count" style="width: 70% !important;">退款时间：{{ item.returnsTime | parseTime('YYYY-MM-DD HH:mm:ss')
          }}
          </view>
          <view class="count" style="width: 30% !important;" v-if="item.status == '0'">退款中</view>
          <view class="count" style="width: 30% !important;" v-if="item.status == '1'">退款成功</view>
          <view class="count" style="width: 30% !important;" v-if="item.status == '2'">退款失败</view>
        </view>
      </view>
      <uni-load-more :status="loading" v-if="orderList.length > 0"></uni-load-more>
      <view
        style="width: 100%;height: 100%;background-color: #f7f7f7;display: flex;justify-content: center;align-items: center;"
        v-if="orderList.length == 0">
        <image src="/static/index/nonedata.png" mode="aspectFill" style="width: 400rpx;height: 400rpx;"></image>
      </view>
    </scroll-view>
  </view>
</template>

<script>
import { reqReturnOrderList } from '@/apis/member.js'
export default {
  name: "InventoryInfo",
  data() {
    return {
      orderList: [], // 供应链标品
      page: {
        pageNum: 1,
        pageSize: 15
      },
      returnsNumber: '',
      triggered: false, // 是否触发下拉刷新
      loading: 'loading', // 是否触发上拉加载
    }
  },
  onLoad() {
    this.reqReturnOrderList()
  },
  onShow() {
  },
  methods: {
    refresherrefreshFn() {
      console.log('233333');
      this.page.pageNum = 1
      this.triggered = true
      this.orderList = []
      this.loading = "loading";
      this.reqReturnOrderList()
    },
    // 供应链 
    async reqReturnOrderList() {
      const res = await reqReturnOrderList({ ...this.page, returnsNumber: this.returnsNumber })
      if (res.code === 200) {
        this.orderList = [...this.orderList, ...res.data.list]
        this.nextPage = res.data.nextPage
        console.log('orderList:', this.orderList);
        this.triggered = false
        if (res.data.isLastPage) {
          this.loading = "noMore"
        }
      }
    },
    lower() {
      console.log('222');
      if (this.loading == "noMore") {
        return;
      }
      this.page.pageNum++;
      this.loading = "loading";
      this.reqReturnOrderList()

    },
    searchFn() {
      console.log('1111111');
      this.page.pageNum = 1
      this.orderList = []
      this.loading = "loading";
      this.reqReturnOrderList()
    },
    clearFn() {
      this.page.pageNum = 1
      this.orderList = []
      this.loading = "loading";
      this.reqReturnOrderList()
    }
  }
}
</script>
<style>
page {
  background: #f7f7f7;

}
</style>
<style lang="scss" scoped >
.content {
  height: 100vh;
  background-color: #f7f7f7;


}

.topCard {
  font-size: 26rpx;
  height: 80rpx;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20rpx;
  // background-color: #fff;
  border: 1px solid #eee;
}

view {
  box-sizing: border-box;
}

.goodsname {
  font-weight: 600;
}

.infoCard {
  // width: 100%;
  background-color: #edf2fa;

  border-radius: 20rpx;
  margin: 20rpx;
  font-size: 26rpx;
  // margin-bottom: 10rpx;
  padding: 20rpx 10rpx;
  align-items: center;
  height: 160rpx;
  line-height: 60rpx;
  border: 1px solid #d3e3fd;
  display: flex;

  .left {
    width: 90%;
  }

  .right {
    width: 10%;
  }

  .tokenNum {

    display: flex;
    width: 100%;
    justify-content: space-between;

    .count {
      width: 48%;
      padding-left: 20rpx;
    }
  }
}

.infoCard2 {
  // width: 100%;
  background-color: #edf2fa;
  // display: flex;
  border-radius: 20rpx;
  margin: 20rpx;
  font-size: 26rpx;
  // margin-bottom: 10rpx;
  padding: 20rpx 10rpx;
  // align-items: center;
  height: 290rpx;
  line-height: 56rpx;
  border: 1px solid #d3e3fd;

  .left {
    width: 90%;
  }

  .right {
    width: 10%;
  }

  .tokenNum {
    display: flex;
    width: 100%;
    justify-content: space-between;

    .count {
      width: 48%;
      padding-left: 20rpx;
    }
  }
}
</style>
